var edit_form_panel = Ext.create("Ext.form.Panel", {
	url: "/fk-acti/form/edit",
	buttonAlign: "center",
	bodyStyle: "padding: 10px;",
	defaultType : "textfield",
	items: [{
			fieldLabel: "表单名称",
			emptyText: "",
			name: "name",
			allowBlank : false,
			width: "100%"
		},{
			fieldLabel: "编号",
			name: "code",
			allowBlank : false,
			width: "100%"
		},{
			fieldLabel: "表单json",
			emptyText: "",
			name: "json",
			allowBlank : false,
			width: "100%"
		},{
			fieldLabel: "表单高级json",
			emptyText: "",
			name: "json_eval",
			allowBlank : true,
			width: "100%"
		},{
			fieldLabel: "kid",
			name: "kid",
			xtype: "hidden",
			width: "100%"	
		}
	],
	buttons: [{
		text: "保存",
		formBind: true, // only enabled once the form is valid
		disabled: true,
		handler: function() {
			var form = this.up("form").getForm();
			if (form.isValid()) {
				form.submit({
					waitMsg: "保存中...",
					success: function(form, action) {
						var message = action.result.result;
						Ext.Msg.alert("提示", message);
						edit_form_panel_win.close();
						dataStore.load();
					},
					failure: function(form, action) {
						Ext.Msg.alert("提示", "操作失败！");
					}
				});
			}
		}
	}]
});

var edit_form_panel_win = Ext.create("Ext.Window", {
	title: "表单修改",
	closeAction: "hide",
	width: 450,
	items: edit_form_panel
});

function myEdit(kid) {
	Ext.Ajax.request({
		url: "/fk-acti/form/edit_form?kid="+kid,
		method: "POST",
		success: function(response) {
			var json = Ext.JSON.decode(response.responseText);
			edit_form_panel.getForm().reset();
			edit_form_panel.getForm().setValues(json.result);
			edit_form_panel_win.show();
		},
		failure: function(response) {
			Ext.Msg.alert("提示", "操作失败!");
		}
	});
} // #myEdit
